package com.sg.hms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sg.hms.Model.Employee;
import com.sg.hms.Service.EmployeeService;
import com.sg.hms.ServiceImpl.EmployeeServiceImpl;
/**
 * 
 * @author 陈良机
 *
 */
public class PersonalUpController extends HttpServlet{
	EmployeeService emservice=new EmployeeServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		int flag=0;
		String elName=req.getParameter("elName");
		String elSex=req.getParameter("elSex");
		int elAge=Integer.parseInt(req.getParameter("elAge"));
		String tellphone=req.getParameter("tellphone");
		int elId=Integer.parseInt(req.getParameter("elId"));
		Employee em=new Employee(elId,elName,elSex,elAge,tellphone);
		if(elName==""||elSex==""||elAge==0||tellphone==""){
			flag=0;
		}else{
			flag= emservice.personalUp(em);
		}
		PrintWriter pw=resp.getWriter();
		pw.write(String.valueOf(flag));
	}
}
